<?php

require('config.php');
define('MAIN_PICTURE',1);
$format = modelUploadFormat::getObject(FORMAT_PREVIEW_PHOTO);
$formatMain = modelUploadFormat::getObject(FORMAT_PREVIEW_MAIN_PHOTO);
$format_zoom = modelUploadFormat::getObject(FORMAT_DETAIL_PHOTO);
$xml_subject = tmxTranslate('subject.mail.xml', REP_XLAT_MAIL);
$id_user = isset($_SESSION['id_user'])?$_SESSION['id_user']:'';
$language_link=$_GET['id'];
if(isset($_GET['view']) && ($language_link != null && $language_link > 0 ))
	$location = modelLocationMap::getList($_GET['id']);
elseif(($language_link != null && $language_link > 0 )) {
	if(modelLocationMap::getExistMyLocation($id_user,$language_link)){
		$location = modelLocationMap::getList($language_link);
	}else $location = modelLocationMap::getList($language_link,1);
}else{
	redirectFront(LANGUAGE_FOLDER."/index");
}
//***update status rented and sold ***//

//***********************************//
		if(isset($_POST['fichier'])){
		 	modelPhoto::unlinkPhotoLocation($_POST['id_fichier']);
		}
		if(isset($_POST['fichier_video'])){
		 	modelVideo::unlinkPhotoLocation($_POST['id_fichier_video']);
		}
		if(isset($_POST['ordre'])){
			$listPhotos = modelPhoto::getListPhotoLocation($language_link);
			foreach($listPhotos as $key => $position) {
	            if(isset($_POST[$position->id_category_location])){
	                $pos = $_POST[$position->id_category_location];
	                $cle = $position->id_category_location;
	                $order[$cle] = $pos;
	            }
	        }
	        modelPhoto::updatePositionLocation($order);
		}
		if(isset($_POST['ordre_video'])){
			$listVideos = modelVideo::getListPhotoLocation($language_link);
			foreach($listVideos as $key => $positions) {
	            if(isset($_POST[$positions->id_location_video])){
	                $pos = $_POST[$positions->id_location_video];
	                $cle = $positions->id_location_video;
	                $order[$cle] = $pos;
	            }
	        }
	        modelVideo::updatePositionLocation($order);
		}
		if(isset($_POST['validated_video_waiting'])){
			modelLocationMap::updatePhotoAndVideoValidate($_POST['id_video_waiting'],LOCATION_VALIDATION);
		}
		if(isset($_POST['refused_video'])){
			modelLocationMap::updatePhotoAndVideoValidate($_POST['id_refused_video'],LOCATION_REFUSE);
		}
		if(isset($_POST['validated_photo_waiting'])){
			modelLocationMap::updatePhotoAndVideoValidate($_POST['id_photo_waiting'],LOCATION_VALIDATION);
		}
		if(isset($_POST['refused_photo'])){
			modelLocationMap::updatePhotoAndVideoValidate($_POST['id_refused_photo'],LOCATION_REFUSE);
		}
		if(isset($_POST['photos'])){
			modelPhoto::setMainPhotosLocation($_POST['id_photo'],$_GET['id']);
		}
		if(isset($_POST['videos'])){
			modelVideo::setMainPhotosLocation($_POST['id_video'],$_GET['id']);
		}
		$id_location_map = $_GET['id'];
		if(isset($_POST['status_waiting'])){
			modelLocationMap::updateValidateLocation($id_location_map,LOCATION_VALIDATION);
			//*****************Send mail**Validate**********//
			$user_properties = modelUser::getUserById($location->user_createur);
			$destinataire = $user_properties->login;
			$subject = $xml_subject['subject_property_validate'];
			$mail = new flyLayout(REP_MAIL.'validate_property.mail.tpl');
	    	$mail->start();
	    	$mail->setVariable('link_property', $_SERVER['HTTP_REFERER']);
	    	$mail->stop();
	    	
	    	//MAIL_NOTIFICATION is used to report the validation of a property
			$destinataire = MAIL_NOTIFICATION;
		    if(STATUS_EMAIL == 0) {
	    		echo $mail;
	    	}else if(STATUS_EMAIL == 1) {
	    		monsterMail($destinataire, $subject, $mail);
	    	}else {
	    		echo $mail;
	    		monsterMail($destinataire, $subject, $mail);
	    	}
	    	redirectFrontHtml($_SERVER['HTTP_REFERER']);

		//*******End send mail*Validate*****//
		}

		if(isset($_POST['validate_refused'])){
			$comment = nl2br(addslashes(trim($_POST['comment_refused'])));
			modelLocationMap::updateValidateLocation($id_location_map,LOCATION_REFUSE,$comment);

			//*****************Send mail**Refuse**********//
			$user_properties = modelUser::getUserById($location->user_createur);
			$destinataire = $user_properties->login;
			$subject = $xml_subject['subject_property_refuse'];
			$mail = new flyLayout(REP_MAIL.'refuse_property.mail.tpl');
	    	$mail->start();
	    	$mail->setVariable('link_property', $_SERVER['HTTP_REFERER']);
	    	$mail->setVariable('mail_comment', $comment);
	    	$mail->stop();

		    if(STATUS_EMAIL == 0) {
	    		echo $mail;
	    	}else if(STATUS_EMAIL == 1) {
	    		monsterMail($destinataire, $subject, $mail);
	    	}else {
	    		echo $mail;
	    		monsterMail($destinataire, $subject, $mail);
	    	}
    		redirectFrontHtml($_SERVER['HTTP_REFERER']);

		//*******End send mail**Refuse****//
		}
		if(isset($_POST['validate_rented'])){
			modelLocationMap::updateValidateLocation($id_location_map,LOCATION_RENTED,null,'rented');
			redirectFrontHtml($_SERVER['HTTP_REFERER']);
		}
		if(isset($_POST['validate_sold'])){
			modelLocationMap::updateValidateLocation($id_location_map,LOCATION_SELL,null,'sold');
			redirectFrontHtml($_SERVER['HTTP_REFERER']);
		}
if(!isset($_SESSION['id_user']) and $location->user_createur != $id_user){
	if(!isset($_GET['view'])){
		if(($location->status!=LOCATION_VALIDATION) and ($location->status==LOCATION_SELL and $location->status==LOCATION_RENTED)){
			redirectFront(LANGUAGE_FOLDER."/index");
		}
	}
}

if(!$location){redirectFront(LANGUAGE_FOLDER."/index");}
$html_name = $location->url_rewriting.'-'.$language_link.'.html';

$listLocaionsRE = modelRealEstate::getListAll($language_link);
$listLocaionsCA = modelMap::getListAll($language_link);
$id_tree = '';
foreach($listLocaionsRE as $re => $lRe){
	if( $lRe->id_menu_left_tree > 0 and  $lRe->id_menu_left_tree != null){
		 $id_tree = $lRe->id_menu_left_tree;
		 break;
	}else{
		$title_not_intree =  $lRe->title ;
		$link_not_intree = $lRe->url_rewriting .'-'.$lRe->language_link.'.html';
		$meta_title_not_intree = $lRe->meta_title ;
		break ;
	}
}
if($id_tree == ''){
	foreach($listLocaionsCA as $ca => $lCa){
		if( $lCa->id_menu_left_tree > 0 and  $lCa->id_menu_left_tree != null){
			 $id_tree = $lCa->id_menu_left_tree;
			 break;
		}
	}
}

$page = new rootLayoutPage();
$page->addJavaScript('keyEnable.js');
$page->addJavaScript('jquery.validate.js');
$page->addStyleSheet('jquery.validate.css');
$page->addJavaScript('preview-image-both.js');
$page->addJavaScript('jQuery.jPopup.translate.js');
$page->addStyleSheet('jPopup.translate.css');
$page->addJavaScript('jQuery.autoLand.price.area.js');
//require(REP_MONSTER_CLASS.'layout/layoutMultiLanguage.class.php');

$translate = tmxTranslate('place_detail.xml', REP_XLAT_TEMPLATE);
$xml_place = tmxTranslate('place-create.xml', REP_XLAT_TEMPLATE,isset($_POST['language_code'])?$_POST['language_code']:'');
//-- Menu Page ----------------------------------------------//
$menu = new layoutMenuLeft();

$menuPage = new layoutMenuPage();
$menuPage->setTable('news');
$menuPage->setIdShow($id_tree);
$menu->setIdShow($id_tree);
$menu->pushMenu($menuPage);

if($location->id_province != '' and $location->id_province > 0){
	$province = modelProvince::getProvince($location->id_province);
	if($province){
		$menuProvince = new layoutMenuProvince();
		$menu->pushMenu($menuProvince);
		$menuProvince->setIdShow($province->id_menu_left_tree);
	}
	
}
if($location->id_district != '' and $location->id_district > 0){
	$district = modelDistrict::getDistrict($location->id_district);
	$menuDistrict = new layoutMenuDistrict();
	$menu->pushMenu($menuDistrict);
	if($district){
		$menuDistrict->setIdShow($district->id_menu_left_tree);
	}
}
if($location->id_province_district != '' and $location->id_province_district > 0){
	$province_district = modelDistrict::getProvinceDistrictById($location->id_province_district);
	$menuProvinceDistrict = new layoutMenuDistrict();
	$menuProvinceDistrict->setIdShow($province_district->id_menu_left_tree);
	$menu->pushMenu($menuProvinceDistrict);
}
if($location->id_tree_keyword != '' and $location->id_tree_keyword > 0){
	$menuKeyword = new layoutMenuKeyword();
	$menuKeyword->setIdShow($location->id_tree_keyword);
	$menu->pushMenu($menuKeyword);
}
$page->setMenuPage($menu);

//--------Menu indicator--------------//
/*$menuIndictor = new layoutMenuIndicator();
$menuIndictor->idTree($locations->id_menu_left_tree);
$menuIndictor->title($locations->title);
$page->setMenuIndicator($menuIndictor);*/
//--------Menu Header-----------------//
//************************//
$arr = array();
$getListUrlLocation = modelLocationMap::getListUrlLocation($language_link);
foreach($getListUrlLocation AS $key=>$Url){
	$arr[$Url->language_code]=$Url->url_rewriting.'-'.$Url->language_link.'.html';
}
$header = new layoutHeader();
$header->setArrayUrl($arr);
$header->setIdShow($id_tree);
$page->setHeader($header);

//************************//

$page->setMenuPage($menu);
$page->setBaliseTitle($location->meta_title);
$page->setDescription($location->meta_description);
$page->setIndex($location->index);
$page->setFollow($location->follow);
$extension = filename_extension($_SERVER['REQUEST_URI']);
$page->setCanonical($html_name);

$xml=tmxTranslate('place_detail.xml', REP_XLAT_TEMPLATE);
$tpl_file='place_detail.tpl';
$location_detail = new flyLayout(REP_TPL . $tpl_file);
$location_detail->start();
$location_detail->hideBlock('message_successful'); 
$location_detail->showBlock("client_request");
//$location_detail->setVariable('rand_captcha',rand(1,100));
$location_detail->hideBlock("error-send");
$location_detail->hideBlock("thanks-send");
$location_detail->showBlock('img_right');
//*******Send email to ** client****//
		if(isset($_POST['client_send'])){
			$your_email = trim(addslashes($_POST['txt_cemail']));
			$your_name = trim(addslashes($_POST['txt_cfname']));
			$your_subject = trim(addslashes($_POST['c_subject']));
			$your_tel = trim(addslashes($_POST['txt_cphone']));
			$link="http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
		    $text_message = nl2br(trim(addslashes($_POST['txt_cmessage'])));
		    //$subject = $xml_subject['contact'];
		    $headers=$your_name.' '.$your_email;
	    	$mail = new flyLayout(REP_MAIL.'sale-rental.mail.tpl');
	    	$mail->start();
	    	$mail->setVariable('subject', $your_subject); 
	    	$mail->setVariable('telephone', $your_tel);   
	    	$mail->setVariable('link', $link); 
	    	$mail->setVariable('text_message', $text_message);
	    	$mail->stop();
	    	
		    if(isValidEmail($your_email)) {
			    if(STATUS_EMAIL == 0) {
		    		echo $mail;
		    	}else if(STATUS_EMAIL == 1) {
		    		monsterMail(SEND_TO, $your_subject, $mail,'',$your_email);
		    	}else {
		    		echo $mail;
		    		monsterMail(SEND_TO, $your_subject, $mail,'',$your_email);
		    	}
		    }
			//*****************get value from form**********//
			/*$subject_ = trim(addslashes($_POST['c_subject']));
			$cemail = trim(addslashes($_POST['txt_cemail']));
			$phone_number = trim(addslashes($_POST['txt_cphone']));
			$full_name = trim(addslashes($_POST['txt_cfname']));
			$link="http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
			$cmessage = strip_tags(nl2br(addslashes(trim($_POST['txt_cmessage']))));
			$headers=$fullname.' '.$cemail;
			$mail = new flyLayout(REP_MAIL.'sale-rental.mail.tpl');
			$mail->start();
	    	$mail->setVariable('subject', $subject_); 
	    	$mail->setVariable('telephone', $phone_number); 
	    	$mail->setVariable('link', $link);
	    	$mail->setVariable('text_message', $cmessage);
	    	$mail->stop();*/
	    	//$getCategoryById = modelCategoryProduct::getCategoryById($language_link);
			//if (isset($_POST["captcha"]) && !empty($_POST["captcha"]) && $_POST['captcha']==$rand_captcha) {
					//echo $captcha;
					/*if(STATUS_EMAIL == 0) {
	    			echo $mail;
			    	}else if(STATUS_EMAIL == 1) {
			    		monsterMail($destinataire, $subject, $mail);
			    	}else {
			    		echo $mail;
			    		monsterMail($destinataire, $subject, $mail);
			    	}*/
				$location_detail->showBlock("thanks-send");
			/*}
			else {
				$location_detail->showBlock("error-send");
			}*/
		}
	// Get Gender


$contact_exist =  modelLocationMap::selectLocationVariable($language_link,$id_user);
$location_detail->setVariable('variable_exist', $contact_exist!=''?'exist':'not_exist');

$boo = false;
$booCA = false;
if($listLocaionsRE->size() > 0){
	foreach($listLocaionsRE as $kee => $locationRE){
		if($locationRE->id_menu_left_tree != null and $locationRE->id_menu_left_tree > 0){
			$boo = true;
			$listPage = modelMenuLeft::completePathFromRoot($locationRE->id_menu_left_tree);
        	$location_detail->resetList('list_new');
			foreach($listPage as $key => $pageAriane) {

				if($listPage->index() == 0) continue; // pour sauter la racine

				//if($listPage->size() == $key+1) break; //ignor current page

				//if($listPage->index() == 0)$location_detail->hideBlock('bar1');else $location_detail->showBlock('bar1');
				//if($key<$listPage->size()-1) $location_detail->showBlock('bar');


				$data = modelMenuLeft::getDataFromContentPage($pageAriane->table_name,$pageAriane->language_link,$pageAriane->language_code);
					if($data){
						$location_detail->setVariable('nom_news',$data->title.' ');
						$url_page = $data->url_rewriting.'-'.$data->language_link.'.html';
						$location_detail->setVariable('url_news', isset($data->url)?$data->url:$url_page);
					}
				$location_detail->parseList('list_new');
			}
			$location_detail->parseList('list_new_all');
		}
	}
	$location_detail->showBlock('indicator');
}/*else{
	$location_detail->showBlock('Not_in_tree');
}*/
if($listLocaionsCA->size() > 0){
	foreach($listLocaionsCA as $kee => $locationCA){
		if($locationCA->id_menu_left_tree != null and $locationCA->id_menu_left_tree > 0){

			$booCA = true;
			$listPage = modelMenuLeft::completePathFromRoot($locationCA->id_menu_left_tree);
        	$location_detail->resetList('list_newCA');
			foreach($listPage as $key => $pageAriane) {

				if($listPage->index() == 0) continue; // pour sauter la racine

				if($listPage->index() == 0)$location_detail->hideBlock('bar1CA');else $location_detail->showBlock('bar1CA');
				if($key<$listPage->size()-1) $location_detail->showBlock('barCA');

				$data = modelMenuLeft::getDataFromContentPage($pageAriane->table_name,$pageAriane->language_link,$pageAriane->language_code);
					if($data){
						$location_detail->setVariable('nom_newsCA', $data->title);
						$url_page = $data->url_rewriting.'-'.$data->language_link.'.html';
						$location_detail->setVariable('url_newsCA', isset($data->url)?$data->url:$url_page);
					}
				$location_detail->parseList('list_newCA');
			}
			/*if($title_not_intree){
				$location_detail->setVariable('nom_not_intree', $title_not_intree);
				$location_detail->setVariable('link_not_intree', $link_not_intree);
				$location_detail->setVariable('meta_title_not_intree', $meta_title_not_intree);
				$location_detail->setVariable('province',($province->title));
				$location_detail->setVariable('url_province',$province->url_rewriting.'-'.$province->language_link.'.html');
				$location_detail->setVariable('title_province',$province->meta_title);
				$location_detail->showBlock('real_not_intree');
			}
			$location_detail->parseList('list_new_allCA');*/
		}
	}
	$location_detail->showBlock('indicatorCA');
}

	if($location->comment<>'' and $location->status==LOCATION_REFUSE){
		$location_detail->setVariable('comment', nl2br($location->comment));
		$location_detail->showBlock('user_comment');
	}
	$location_detail->setVariable('get_comment_refused', nl2br($location->comment));
	$location_detail->setVariable('visible',$location->visible?'Yes':'No');
	$location_detail->setVariable('status_location',$location->status_location);

	if($location->status==LOCATION_WAITTING_VALIDATION and modelUser::isUserGroupAdmin($id_user)){
		$location_detail->showBlock('validate');
	}else{
		$location_detail->hideBlock('validate');
	}
	if($location->status==LOCATION_REFUSE){
		$location_detail->hideBlock('refused');
	//}elseif(($location->status==LOCATION_WAITTING_VALIDATION or $location->status==LOCATION_VALIDATION) and (modelUser::isUserGroupAdmin($_SESSION['id_user']))){
	}elseif(($location->status==LOCATION_WAITTING_VALIDATION) and (modelUser::isUserGroupAdmin($id_user))){
		$location_detail->showBlock('refused');
	}
	
	if(($location->status==LOCATION_VALIDATION) and (($location->user_createur == $id_user) or (modelUser::isUserGroupAdmin($id_user)))){
		$list_category_property = modelMap::getCategoryByProperty($language_link);
		foreach ($list_category_property AS $key =>$category_property){
			if($category_property->link==ID_CATEGORY_SALE){//For sale
				$location_detail->showBlock('rented_sold');
			}
			if($category_property->link==ID_CATEGORY_RENT){//For rent
				$location_detail->showBlock('rented_rented');
			}
			if($category_property->link==ID_CATEGORY_SALE and $category_property->link==ID_CATEGORY_RENT){//For rent and sale
				$location_detail->showBlock('rented_sold');
				$location_detail->showBlock('rented_rented');
			}
		}		
	}

	
	if($location->name_place!=''){
		$location_detail->setVariable('place_name',htmlspecialchars($location->name_place));
		$location_detail->setVariable('place_name_slash',htmlspecialchars(addslashes($location->name_place)));
	}else{
		$name_place = '';
		$listKeyword = modelKeyWord::getKeywordByIDLocation($location->language_link,2);
		if($listKeyword->size() > 0){
			foreach($listKeyword as $k => $key2){
				$name_place .= $key2->title.' ';
			}
		$location_detail->setVariable('place_name', $name_place);
		$location_detail->setVariable('place_name_slash',$name_place);
		}
	}

	if($location->address!=''){
		$location_detail->setVariable('address', nl2br($location->address));

		//$location_detail->setVariable('map_address', nl2br($location->address));
		$location_detail->showBlock('show_address');
	}
	if($location->content!=''){
		$location_detail->setVariable('full_description', nl2br($location->content));
		$location_detail->showBlock('show_full_description');
	}else{
		$content = '';
		$listKeyword = modelKeyWord::getKeywordByIDLocation($location->language_link,1);
		if($listKeyword->size() > 0){
			foreach($listKeyword as $k => $key1){
				$br = $key1->id_key==0?'. <br />':', ';
				$content .= $key1->title.$br.' ';
			}
			$content = preg_replace('!,([\s]*)\.!iUs', '.', $content);
			$content = substr(trim($content),0,-1);
			$content__ = '';
			$content = split('. <br />',$content);
			$count = count($content);
			for($x = 0;  $x < $count; $x++){
					$content_ = trim($content[$x]);
					if($x==$count-1){
						if($_SESSION['language_code']=='kh'){
							$content__ .= $content_.'.<br />';
						}else{
							$content__ .= strtoupper(substr($content_,0,1)).(substr($content_,1));
						}
					}else{
						if($_SESSION['language_code']=='kh'){
							$content__ .= $content_.'.<br />';
						}else{
							$content__ .= strtoupper(substr($content_,0,1)).(substr($content_,1)).'.<br />';
						}
					}
			}
		$location_detail->setVariable('full_description', nl2br($content__));
		$location_detail->showBlock('show_full_description');
		}
	}
	if(($location->status == LOCATION_SELL) or ($location->status == LOCATION_RENTED)){
		//$location_detail->setVariable('text_reanted_sold', $location->status_location);
		if($location->status == LOCATION_SELL){
			$location_detail->setVariable('text_reanted_sold', 'logo_sold_'.$_SESSION['language_code']);
		}
		if($location->status == LOCATION_RENTED){
			$location_detail->setVariable('text_reanted_sold', 'logo_rent_'.$_SESSION['language_code']);
		}		
		$location_detail->showBlock('text_reanted_sold');
	}
	$province = modelProvince::getProvince($location->id_province);
	$location_detail->setVariable('province',($province->title));
	$location_detail->setVariable('url_province',$province->url_rewriting.'-'.$province->language_link.'.html');
	$location_detail->setVariable('title_province',$province->meta_title);

	$all_price = modelMap::getPrice($location->id_map_address_price);
	if($all_price and $all_price->price_rental>0 and $all_price->price_rental != null){
		$location_detail->setVariable('price_rental', number_format($all_price->price_rental,0,'.',' ').' '.CURRENCY);
		$location_detail->showBlock('price_rental');
	}
	if($location->length<>0){
		$location_detail->setVariable('length', $location->length);
		$location_detail->showBlock('length');
	}
	if($location->width<>0){
		$location_detail->setVariable('width', $location->width);
		$location_detail->showBlock('width');
	}
	if($location->height<>0){
		$location_detail->setVariable('height', $location->height);
		$location_detail->hideBlock('height');
	}
	if($all_price and $all_price->price_sell>0 and $all_price->price_sell != null){
		$location_detail->setVariable('price_sell', number_format($all_price->price_sell,0,'.',' ').' '.CURRENCY);	
		$list_category_property = modelMap::getCategoryByProperty($language_link);
		foreach ($list_category_property AS $key =>$category_property){//echo ($all_price->price_sell)/($location->size_land);
			if($category_property->link==ID_CATEGORY_SALE){//For sale
				$location_detail->setVariable('total_hata', ($location->size_building)>=10000?(($location->size_building)/10000).'ha':'');
				$num2 = ($location->size_building)==0?0:(($all_price->price_sell)/($location->size_building));
				$total_price_in_ha = substr($all_price->price_sell,-2,2)=='00'?(number_format($num2,0,'.',' ')):(number_format($num2,2,'.',' '));
				$location_detail->setVariable('total_price_in_ha', $total_price_in_ha.CURRENCY.'/m2');
				
				$location_detail->setVariable('total_land_hata', ($location->size_land)>=10000?(($location->size_land)/10000).'ha':'');
				$num1 = ($location->size_land)==0?0:(($all_price->price_sell)/($location->size_land));
				//$total_price_land_in_ha = substr($all_price->price_sell,-2,2)=='00'?(number_format($num1,0,'.',' ')):(number_format($num1,2,'.',' '));		
				$location_detail->setVariable('total_price_land_in_ha', number_format($num1,2,'.',' ').CURRENCY.'/m2');
			}
		}
		$location_detail->showBlock('price_sell');
	}
	//echo number_format($num1,0,'.',' ');
	if($location->size_building<>0){
		$location_detail->setVariable('size_building', $location->size_building);
		$location_detail->hideBlock('size_building');
	}
	if($location->length_land<>0){
		$location_detail->setVariable('length_land', $location->length_land);
		$location_detail->showBlock('length_land');
	}
	if($location->width_land<>0){
		$location_detail->setVariable('width_land', $location->width_land);
		$location_detail->showBlock('width_land');
	}
	if($location->size_land<>0){
		$location_detail->setVariable('size_land', $location->size_land);		
		$location_detail->hideBlock('size_land');
	}
	if($location->bedrooms<>0){
		$location_detail->setVariable('bedroom', $location->bedrooms);
		$location_detail->showBlock('bedroom');
	}
	if($location->bathrooms<>0){
		$location_detail->setVariable('bathroom', $location->bathrooms);
		$location_detail->showBlock('bathroom');
	}
	if($location->mezzanine){
		//$location_detail->setVariable('mezzanine', $location->mezzanine?YES:NO);
		$location_detail->hideBlock('mezzanine');
	}
	if($location->furnished_apartment){
		//$location_detail->setVariable('furnished_apartment', $location->furnished_apartment?YES:NO);
		$location_detail->hideBlock('furnished_apartment');
	}

	if($location->furnished_detail!=''){
		$location_detail->setVariable('furnished_detail', nl2br($location->furnished_detail));
		$location_detail->showBlock('furnished_detail');
	}
	if($location->floor<>0){
		$location_detail->setVariable('floor', $location->floor);
		$location_detail->showBlock('floor');
	}
	if($location->number_floor<>0){
		$location_detail->setVariable('number_floor', $location->number_floor);
		$location_detail->hideBlock('number_floor');
	}
	if($location->tenant){
		//$location_detail->setVariable('tenant', $location->tenant?YES:NO);
		$location_detail->hideBlock('tenant');
	}

	if($location->end_tenant>0){
		$location_detail->setVariable('end_tenant', affiche($location->end_tenant,'date'));
		$location_detail->hideBlock('end_tenant');
	}
	if($location->reference<>""){
		$location_detail->setVariable('reference', $location->reference);
		$location_detail->showBlock('reference');
	}
	if($location->name_district<>""){
		$location_detail->setVariable('district', $location->name_district);
		$location_detail->hideBlock('district');
	}
	if($location->name_province<>""){
		$location_detail->setVariable('province', $location->name_province);
		
	}
	//$location_detail->setVariable('url_category_map', $location->url_rewriting.'-'.$location->language_link.'.html');
	if($location->latitude and DISPLAY_MAP_FRONT==1){
		$page->importJavaScriptTop('http://maps.google.com/maps/api/js?sensor=false');
		$page->addJavaScript('uiMap/jquery.fn.gmap.js');
		$page->addJavaScript('uiMap/jquery.ui.map.services.js');

		$location_detail->setVariable('latitude', $location->latitude);
	$location_detail->setVariable('longitude', $location->longitude);
	$location_detail->setVariable('index', $language_link);
	$location_detail->setVariable('latitude_map', $location->latitude!=''?$location->latitude:DEFAUFT_LATITUDE);
	$location_detail->setVariable('longitude_map',$location->longitude!=''?$location->longitude:DEFAUFT_LONGITUDE);
	$location_detail->setVariable('zome_level', DEFAUFT_ZOME_LEVEL_DETAIL);
		
		$location_detail->showBlock('map_canvas_location');
	}else{
		$location_detail->hideBlock('map_canvas_location');
	}

	

	$location_detail->setVariable('language_link', $location->language_link);
	if($location->language_link){
		$language_link__ = $location->language_link;
	}else{
		$language_link__ = '';
	}
	if(isset($_SESSION['id_user']) and $location->user_createur == $id_user){
		$photo_map = modelPhoto::getMainPhotoLocation($language_link__);
		if($photo_map){
			$id_fichier = $photo_map->id_fichier;
		}else{$id_fichier='';}
	}else{
		$photo_map = modelPhoto::getMainPhotoLocation_out($language_link__);
		if($photo_map){
			$id_fichier = $photo_map->id_fichier;
		}else{$id_fichier='';}
		
	}
	$format_map = modelUploadFormat::getObject(FORMAT_PREVIEW_MAP);
	$fichier_map = modelUploadFile::getObject($id_fichier);
	if($fichier_map){
		$url_image_map = $fichier_map->url_repertoire.$format_map->url_format.$fichier_map->nom_serveur;
	}else{
		$url_image_map = '';
	}
	if(file_exists($url_image_map)){
		list($width, $height, $type, $attr) = getimagesize($fichier_map->url_repertoire.$format_map->url_format.$fichier_map->nom_serveur);
		$url_image_map = $fichier_map->url_repertoire.$format_map->url_format.$fichier_map->nom_serveur;
		$location_detail->setVariable('map_photo',($url_image_map));
		$location_detail->setVariable('map_width',$width.'px');
		$location_detail->setVariable('map_height',$height.'px');
		$location_detail->showBlock('map_image');
	}else{
		$location_detail->setVariable('map_photo', '');
		$location_detail->hideBlock('map_image');
	}

	if(isset($location->name_place)){
		$location_detail->showBlock('place_name');
	}
	if(isset($location->address) and DISPLAY_ADDRESS_FRONT==1){
		$location_detail->showBlock('address');
	}
	if(isset($location->name_city)){
		$location_detail->showBlock('city');
	}
	if(isset($location->name_province)){
		$location_detail->showBlock('province');
	}
	if(isset($location->name_district)){
		$location_detail->showBlock('district');
	}
	if(isset($location->zip_code)){
		$location_detail->showBlock('zip_code');
	}

$m_photo = modelPhoto::getPhotoLocation($language_link);
if(!$m_photo) modelPhoto::getIDPhotoLocation($language_link)?modelPhoto::setMainPhotosLocation(modelPhoto::getIDPhotoLocation($language_link),$language_link):'';
$listPhotos = modelPhoto::getListPhotoLocation($location->language_link);

$m_video = modelVideo::getPhotoLocation($language_link);
if(!$m_video) modelVideo::getIDPhotoLocation($language_link)?modelVideo::setMainPhotosLocation(modelVideo::getIDPhotoLocation($language_link),$language_link):'';
$listVideos = modelVideo::getListPhotoLocation($location->language_link);
//echo "id_user=".$_SESSION['id_user'].'location->user_createur='.$location->user_createur;
if((isset($_SESSION['id_user']) and $location->user_createur == $_SESSION['id_user']) or modelUser::isUserGroupAdmin($id_user)){
		$num = 10;
	    if($listPhotos->size() > 0) {
	        foreach($listPhotos as $key => $photo){
	        	$fichier = modelUploadFile::getObject($photo->id_fichier);
				if($fichier){
					$url_image = $fichier->url_repertoire.FORMAT_MINI_ADMIN.$fichier->nom_serveur;
					$url_image_preview = $fichier->url_repertoire.FORMAT_FOLDER_PREVIEW_ADMIN.$fichier->nom_serveur;
					if(file_exists($url_image)){
							$location_detail->setVariable('src_image', $url_image);
					}else{
						$location_detail->setVariable('src_image', NOIMAGE_SMALL);
					}
					if(file_exists($url_image_preview)){
						$location_detail->setVariable('src_image_preview', $url_image_preview);
					}else{
						$location_detail->setVariable('src_image_preview', NOIMAGE);
					}
				}

					
					if($fichier){
						$location_detail->setVariable('id_fichier_validate_photo', $fichier->id_fichier);
						if(file_exists($fichier->url_repertoire.$format_zoom->url_format.$fichier->nom_serveur)){
							$url_image_zoom_1 = $fichier->url_repertoire.$format_zoom->url_format.$fichier->nom_serveur;
						}else{
							$url_image_zoom_1 = REP_DESIGN.'noimage.jpg';
						}
					}else{
						$url_image_zoom_1 = REP_DESIGN.'noimage.jpg';
					}
					$location_detail->setVariable('url_photo_list_zoom', $url_image_zoom_1);

					//--------------------------------

				if($fichier){
					if($fichier->status==1 and modelUser::isUserGroupAdmin($id_user)){
					$location_detail->showBlock('status_validate_photo');
					}else{
						$location_detail->hideBlock('status_validate_photo');
					}
					if($fichier->status==4){
						$location_detail->hideBlock('status_Refused_photo');
					}elseif(($fichier->status==1 or $fichier->status==2) and (modelUser::isUserGroupAdmin($id_user))){$location_detail->showBlock('status_Refused_photo');}
						
				}
	    		$location_detail->setVariable('type_ligne', ($listPhotos->index()%2==1)?'pair':'impair');
	    		$location_detail->setVariable('status', $photo->status_photo);
	        	$location_detail->setVariable('position', $num);
	        	$location_detail->setVariable('id_fichier', $photo->id_category_location);

	    		$location_detail->setVariable('id_link',$language_link);
	    		$location_detail->setVariable('id_photo_category',$photo->id_fichier);
	    		if($photo->main_photos == MAIN_PICTURE){
	    			$location_detail->showblock('status_main_photo');
	    			$location_detail->hideblock('button_main_photo');
				}
				else{
					if($photo->status==4){
						$location_detail->hideblock('status_main_photo');
		    			$location_detail->hideblock('button_main_photo');
					}else{
						$location_detail->hideblock('status_main_photo');
	    				$location_detail->showblock('button_main_photo');
					}
				}

	    		$location_detail->parseList('listPhotos');
	    		$num = $num + 10;
	    	}
	       $location_detail->showBlock('liste');
	    }

		$num = 10;
		$url_image_defaulf = '_design/'."player_mini.png";
	    if($listVideos->size() > 0) {
	        foreach($listVideos as $key => $video){
	    		$location_detail->setVariable('type_ligne_video', ($listVideos->index()%2==1)?'pair':'impair');
	    		$location_detail->setVariable('status_video', $video->status_video);
	        	$location_detail->setVariable('position_video', $num);
	        	$location_detail->setVariable('id_fichier_video', $video->id_location_video);

	    		$location_detail->setVariable('id_link_video',$language_link);
	    		$location_detail->setVariable('id_category_video',$video->id_fichier);
	    		if($video->main_videos == MAIN_PICTURE){
    				$location_detail->showblock('status_main_video');
	    			$location_detail->hideblock('button_main_video');
					//$location_detail->setVariable('status_main_videos',$translate['botton_4']);
				}else{
					if($video->status==4){
						$location_detail->hideblock('status_main_video');
		    			$location_detail->hideblock('button_main_video');
	    			}else{
						$location_detail->hideblock('status_main_video');
		    			$location_detail->showblock('button_main_video');
					}
				}

				$video_path = PATH_ROOT.PATH_FILES;
				$nom_serveur = $video->nom_serveur;
				$video_path_name = $video_path.$nom_serveur;
				$fichier_video = modelUploadFile::getObject($video->id_fichier);
				if(file_exists($video_path_name)){
						$videoImage = getVideoImage(REP_FRONT_VIDEO_IMAGE.$video->nom_serveur);
						$location_detail->setVariable('duration',affiche($video->duration,'video_time'));
						$location_detail->setVariable('width', VIDEO_IMAGE_LIST_WIDTH);
						$location_detail->setVariable('height', VIDEO_IMAGE_LIST_HEIGHT);
						$location_detail->setVariable('src_image_play', $videoImage['base64']);
    					$location_detail->setVariable('script_change_thumbnail', "javascript:change_thumbnail(".$video->id_fichier.")");
    					$location_detail->setVariable('id_fichier_validate_video', $fichier_video->id_fichier);
				}else{
					$location_detail->setVariable('width', VIDEO_IMAGE_LIST_WIDTH);
					$location_detail->setVariable('height', VIDEO_IMAGE_LIST_HEIGHT);
					$location_detail->setVariable('src_image_play', $url_image_defaulf);
	    			$location_detail->setVariable('script_change_thumbnail', "javascript:change_thumbnail('')");
				}

				if($fichier_video->status==1 and modelUser::isUserGroupAdmin($id_user)){
					$location_detail->showBlock('status_validate_video');
				}else{
					$location_detail->hideBlock('status_validate_video');
				}
				if($fichier_video->status==4){
					$location_detail->hideBlock('status_Refused_video');
				}elseif(($fichier_video->status==1 or $fichier_video->status==2) and (modelUser::isUserGroupAdmin($id_user))){$location_detail->showBlock('status_Refused_video');}

				$location_detail->setVariable('url',HTTP_HOST.$video->url_repertoire.$video->nom_serveur);

				$start = $video->thumbnail_at_frame_number;
				$location_detail->setVariable('start_frame',$start);
				$location_detail->setVariable('filename',$video->nom_serveur);
				$location_detail->setVariable('selected_frame',$start);
				$location_detail->setVariable('id_video', $video->id_fichier);

				$location_detail->setVariable('rep_ajax',REP_AJAX.'upload/');
	    		$location_detail->parseList('list_video');
	    		$num = $num + 10;
	    	}
	    	$location_detail->setVariable('lang',isset($_GET['lang'])?$_GET['lang']:'');
	       $location_detail->showBlock('liste_video');
	    }
	    $location_detail->showBlock('sesstion_user');
	    $location_detail->showBlock('sesstion_user_1');
	    if(($location->status==LOCATION_SELL or $location->status==LOCATION_RENTED)){
	    	$location_detail->hideBlock('sesstion_user_1');	    	
			$listPhotos_out = modelPhoto::getListPhotoLocation_out($location->language_link);
			if($listPhotos_out->size() > 0) {
				foreach($listPhotos_out as $key => $fichier) {
					$url_image = $fichier->url_repertoire.$format->url_format.$fichier->nom_serveur;
					$url_image_zoom = $fichier->url_repertoire.$format_zoom->url_format.$fichier->nom_serveur;
		
					if(file_exists($url_image)){
						$location_detail->setVariable('url_profil_photo_no_session', $url_image);
					}else{
						$location_detail->setVariable('url_profil_photo_no_session', NOIMAGE);
					}
					if(file_exists($url_image_zoom)){
						$location_detail->setVariable('url_profil_photo_zoom_no_session', $url_image_zoom);
					}else{
						$location_detail->setVariable('url_profil_photo_zoom_no_session', NOIMAGE);
					}
		
					$location_detail->setVariable('title_no_session', $fichier->nom_initial);
					$location_detail->setVariable('titre_no_session', $fichier->titre);
						if($fichier->titre != '' and $fichier->author != '' and $fichier->description != '') $location_detail->setVariable('des_img_no_session', $fichier->titre.' '.'-'.' '.$fichier->author.'<br />'.nl2br($fichier->description));
						else if($fichier->titre == '' and $fichier->author != '' and $fichier->description != '') $location_detail->setVariable('des_img_no_session', $fichier->author.'<br />'.nl2br($fichier->description));
						else if($fichier->titre != '' and $fichier->author == '' and $fichier->description != '') $location_detail->setVariable('des_img_no_session', $fichier->titre.'<br />'.nl2br($fichier->description));
						else if($fichier->titre != '' and $fichier->author != '' and $fichier->description == '') $location_detail->setVariable('des_img_no_session', $fichier->titre.' '.'-'.' '.$fichier->author);
						else if($fichier->titre != '' and $fichier->author == '' and $fichier->description == '') $location_detail->setVariable('des_img_no_session', $fichier->titre);
						else if($fichier->titre == '' and $fichier->author != '' and $fichier->description == '') $location_detail->setVariable('des_img_no_session', $fichier->author);
						else if($fichier->titre == '' and $fichier->author == '' and $fichier->description != '') $location_detail->setVariable('des_img_no_session', nl2br($fichier->description));
						else $location_detail->setVariable('des_img_no_session', '');
					$location_detail->parseList('list_photo_no_session');
				}
				$location_detail->showBlock('liste_no_session');
			}
		
			//==================video=======================
			$listVideos_out = modelVideo::getListPhotoLocation_out($location->language_link);
		     if($listVideos_out->size() > 0) {
		     	$url_image_defaulf = '_design/'."player_big.png";
			        foreach($listVideos_out as $key => $video){
						$location_detail->setVariable('url_no_session',HTTP_HOST.$video->url_repertoire.$video->nom_serveur);
						if(file_exists($video->url_repertoire.$video->nom_serveur)){
							$videoImage = getVideoImage(REP_FRONT_VIDEO_IMAGE.$video->nom_serveur);
							$location_detail->setVariable('duration',affiche($video->duration,'video_time'));//just open
							$location_detail->setVariable('width', '120px');
							$location_detail->setVariable('height', '100px');
							$location_detail->setVariable('src_image_no_session', $videoImage['base64']);
						}else{
							$location_detail->setVariable('width', '120px');
							$location_detail->setVariable('height', '100px');
							$location_detail->setVariable('src_image_no_session', $url_image_defaulf);
						}
			    		$location_detail->parseList('list_video_no_session');
			    	}
			       $location_detail->showBlock('liste_video_no_session1');
		    }
	    	$location_detail->showBlock('no_sesstion_user');
	    	//$location_detail->showBlock('liste_no_session');
	    	//$location_detail->showBlock('liste_video_no_session1');
	    }
	    
	    $location_detail->showBlock('connection');

}else{
	$listPhotos_out = modelPhoto::getListPhotoLocation_out($location->language_link);
	if($listPhotos_out->size() > 0) {
		foreach($listPhotos_out as $key => $fichier) {
			$url_image = $fichier->url_repertoire.$format->url_format.$fichier->nom_serveur;
			$url_image_zoom = $fichier->url_repertoire.$format_zoom->url_format.$fichier->nom_serveur;

			if(file_exists($url_image)){
				$location_detail->setVariable('url_profil_photo_no_session', $url_image);
			}else{
				$location_detail->setVariable('url_profil_photo_no_session', NOIMAGE);
			}
			if(file_exists($url_image_zoom)){
				$location_detail->setVariable('url_profil_photo_zoom_no_session', $url_image_zoom);
			}else{
				$location_detail->setVariable('url_profil_photo_zoom_no_session', NOIMAGE);
			}

			$location_detail->setVariable('title_no_session', $fichier->nom_initial);
			$location_detail->parseList('list_photo_no_session');
		}
		$location_detail->showBlock('liste_no_session');
	}

	//==================video=======================
	$listVideos_out = modelVideo::getListPhotoLocation_out($location->language_link);
     if($listVideos_out->size() > 0) {
     	$url_image_defaulf = '_design/'."player_big.png";
	        foreach($listVideos_out as $key => $video){
				$location_detail->setVariable('url_no_session',HTTP_HOST.$video->url_repertoire.$video->nom_serveur);
				if(file_exists($video->url_repertoire.$video->nom_serveur)){
					$videoImage = getVideoImage(REP_FRONT_VIDEO_IMAGE.$video->nom_serveur);
					$location_detail->setVariable('duration',affiche($video->duration,'video_time'));//just open
					$location_detail->setVariable('width', '120px');
					$location_detail->setVariable('height', '100px');
					$location_detail->setVariable('src_image_no_session', $videoImage['base64']);
				}else{
					$location_detail->setVariable('width', '120px');
					$location_detail->setVariable('height', '100px');
					$location_detail->setVariable('src_image_no_session', $url_image_defaulf);
				}
	    		$location_detail->parseList('list_video_no_session');
	    	}
	       $location_detail->showBlock('liste_video_no_session1');
    }
	$location_detail->showBlock('no_sesstion_user');
	$location_detail->showBlock('desconnec');
}

if(((isset($_SESSION['id_user']) and $location->user_createur == $_SESSION['id_user']) or modelUser::isUserGroupAdmin($id_user))){
	$main_video = modelVideo::getMainVideoLocation($location->language_link);
	$photo = modelPhoto::getMainPhotoLocation($location->language_link);
	$menutabMultiLanguage = new layoutMultiLanguage('layoutMultiLanguage.tpl',REP_MONSTER_LAYOUT);
	if(($location->status!=LOCATION_SELL and $location->status!=LOCATION_RENTED)){
		$menutabMultiLanguage->setUrlPageCreaterFront('place-translate.php');
		/////Don't display admin page
		//$location_detail->showBlock('modify_place');
		///////////////////////////
		
		
		
		//no_sesstion_user
	}
	
	
	$menutabMultiLanguage->setUrl($html_name);
	$menutabMultiLanguage->setArrayUrl($arr);
	$menutabMultiLanguage->setObject($location);
	$menutabMultiLanguage->setTable('category_map_address');
	//$location_detail->includeLayout('menubarMultiLanguage', $menutabMultiLanguage);
	//$location_detail->showBlock('detail_own');
	//$location_detail->hideBlock('tab_detail_not_owner');
	/////////Don't show admin /////
	$menutabMultiLanguageNotOwner = new layoutMultiLanguage('layoutMultiLanguage.tpl',REP_MONSTER_LAYOUT);
	$menutabMultiLanguageNotOwner->setUrlPageCreaterEmpty('lang');
	$menutabMultiLanguageNotOwner->setUrl($html_name);
	$menutabMultiLanguageNotOwner->setArrayUrl($arr);
	$menutabMultiLanguageNotOwner->setObject($location);
	$menutabMultiLanguageNotOwner->setTable('category_map_address');
	$location_detail->includeLayout('menutabMultiLanguageNotOwner', $menutabMultiLanguageNotOwner);
	$location_detail->hideBlock('tab_detail_not_owner');
	////////////////////////////////
	
}elseif(isset($_SESSION['id_user']) and $location->user_createur != $_SESSION['id_user']) {
	$menutabMultiLanguageNotOwner = new layoutMultiLanguage('layoutMultiLanguage.tpl',REP_MONSTER_LAYOUT);
	$menutabMultiLanguageNotOwner->setUrlPageCreaterEmpty('lang');
	$menutabMultiLanguageNotOwner->setUrl($html_name);
	$menutabMultiLanguageNotOwner->setArrayUrl($arr);
	$menutabMultiLanguageNotOwner->setObject($location);
	$menutabMultiLanguageNotOwner->setTable('category_map_address');
	$location_detail->includeLayout('menutabMultiLanguageNotOwner', $menutabMultiLanguageNotOwner);
	//$location_detail->hideBlock('detail_own');
	$location_detail->hideBlock('tab_detail_not_owner');
}else{
	$main_video = modelVideo::getMainVideoLocation_out($location->language_link);
	$photo = modelPhoto::getMainPhotoLocation_out($location->language_link);
	$menutabMultiLanguageNotOwner = new layoutMultiLanguage('layoutMultiLanguage.tpl',REP_MONSTER_LAYOUT);
	$adm = isset($_GET['view'])?'view':'lang';
	$menutabMultiLanguageNotOwner->setUrlPageCreaterEmpty($adm);
	$menutabMultiLanguageNotOwner->setUrl($html_name);
	$menutabMultiLanguageNotOwner->setArrayUrl($arr);
	$menutabMultiLanguageNotOwner->setObject($location);
	$menutabMultiLanguageNotOwner->setTable('category_map_address');
	$location_detail->includeLayout('menutabMultiLanguageNotOwner', $menutabMultiLanguageNotOwner);
	//$location_detail->hideBlock('detail_own');
	$location_detail->hideBlock('tab_detail_not_owner');
}

//============== display main video===================//
$location_detail->showBlock('main_ads');
	if(isset($main_video->nom_serveur)){
		$location_detail->setVariable('url_video_main',HTTP_HOST.$main_video->url_repertoire.$main_video->nom_serveur);
		$url_ = $main_video->url_repertoire.$main_video->nom_serveur;
	}else $url_='';
	
	if(file_exists($url_)){
		$videoImage = getVideoImage(REP_FRONT_VIDEO_IMAGE.$main_video->nom_serveur);
		$location_detail->setVariable('duration',affiche($main_video->duration,'video_time'));
		$location_detail->setVariable('width', VIDEO_IMAGE_FORMART_WIDTH);
		$location_detail->setVariable('height', VIDEO_IMAGE_FORMART_HEIGHT);
		$location_detail->setVariable('src_video_main', $videoImage['base64']);
		$location_detail->showBlock("video");
	}else{
		$location_detail->hideBlock("video");
	}

$location_detail->setVariable('id_user',$id_user);
$location_detail->setVariable('id_location',$_GET['id']);
$location_detail->setVariable('REP_AJAX',REP_AJAX.'contact_owner.php');
$location_detail->setVariable('REP_AJAX_VARIABLE',REP_AJAX.'contact_variable.php');
$location_detail->setVariable('owner_or_not',($location->user_createur == $id_user?'owner':'no_owner'));

//============== display main photo==================//

	if(isset($photo->id_fichier)){
		$fichier = modelUploadFile::getObject($photo->id_fichier);
	}else{
		$fichier ='';
	}
		if($fichier){ 
			//$url_image = $fichier->url_repertoire.$formatMain->url_format.$fichier->nom_serveur;
			//$url_image = $fichier->url_repertoire.$formatMain->url_format.$fichier->nom_serveur;
			$url_image = $fichier->url_repertoire.$format_zoom->url_format.$fichier->nom_serveur;
			$url_image_face = REP_PHOTO_SOCIAL.$fichier->nom_serveur;
			$url_image_zoom_1 = $fichier->url_repertoire.$format_zoom->url_format.$fichier->nom_serveur;
			if(file_exists($url_image)){
				list($width, $height, $type, $attr) = getimagesize($fichier->url_repertoire.$formatMain->url_format.$fichier->nom_serveur);
				$location_detail->setVariable('src_photo', $url_image);
				//$location_detail->setVariable('width_photo',$width.'px');
				//$location_detail->setVariable('height_photo',$height.'px');
			}else{
				$location_detail->setVariable('src_photo', NOIMAGE);
			}
			if(file_exists($url_image_face)) $page->setFacebookImage("http://".$_SERVER["SERVER_NAME"].'/'.$url_image_face);

			$location_detail->setVariable('title_photo',$location->meta_title);
			$location_detail->showBlock("main_photo");
		}

$location_detail->stop();
$page->setBody($location_detail);
$page->display();

?>